package com.geovis.emergency.spd.controller.resources;

import com.geovis.common.core.api.Result;
import com.geovis.emergency.spd.biz.resources.service.BsFxkhzjzService;
import com.geovis.emergency.spd.biz.resources.service.BsShyjjydwService;
import com.geovis.emergency.spd.biz.resources.service.BsZhxxdwryService;
import com.geovis.emergency.spd.biz.resources.service.JzwzcbkdService;
import com.geovis.emergency.spd.entity.resources.dto.*;
import com.geovis.emergency.spd.entity.resources.entity.BsFxkhzjz;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 应急资源接口
 * </p>
 *
 * @author 王响
 * @since 2020-07-15
 */
@RestController
@RequestMapping("/resources")
@RequiredArgsConstructor
@Api(value = "应急资源接口", tags = "应急资源接口")
@Slf4j
@Validated
public class ResourcesController {

    private final BsShyjjydwService bsShyjjydwService;

    private final JzwzcbkdService jzwzcbkdService;

    private final BsFxkhzjzService bsFxkhzjzService;

    private final BsZhxxdwryService zhxxdwryService;

    @ApiOperation(value = "物资仓库-列表", notes = "物资仓库-列表")
    @GetMapping("/getJzwzcbkd")
    public Result<List<ResourceListDTO>> getJzwzcbkd() {

        return Result.ok(jzwzcbkdService.getJzwzcbkd());

    }

    @ApiOperation(value = "物资仓库-明细", notes = "物资仓库-明细")
    @GetMapping("/getJzwzcbkdDetail")
    public Result<JzwzcbkdDetailDTO> getJzwzcbkdDetail(String id) {

        return Result.ok(jzwzcbkdService.getJzwzcbkdDetail(id));

    }

    @ApiOperation(value = "社会救援队伍-列表", notes = "社会救援队伍-列表")
    @GetMapping("/getShyjjydw")
    public Result<List<ResourceListDTO>> getShyjjydw() {

        return Result.ok(bsShyjjydwService.getShyjjydw());

    }

    @ApiOperation(value = "社会救援队伍-明细", notes = "社会救援队伍-明细")
    @GetMapping("/getShyjjydwDetail")
    public Result<BsShyjjydwDetailDTO> getShyjjydwDetail(String id) {

        return Result.ok(bsShyjjydwService.getShyjjydwDetail(id));

    }

    @ApiOperation(value = "专家力量-列表", notes = "专家力量-列表")
    @GetMapping("/getFxkhzjz")
    public Result<List<ResourceListDTO>> getFxkhzjz() {

        return Result.ok(bsFxkhzjzService.getFxkhzjz());

    }

    @ApiOperation(value = "专家力量-明细", notes = "专家力量-明细")
    @GetMapping("/getFxkhzjzDetail")
    public Result<List<BsFxkhzjzDetailDTO>> getFxkhzjzDetail() {

        return Result.ok(bsFxkhzjzService.getFxkhzjzDetail());

    }

    @ApiOperation(value = "责任人-列表", notes = "责任人-列表")
    @GetMapping("/getZhxxdwry")
    public Result<List<ResourceListDTO>> getZhxxdwry() {

        return Result.ok(zhxxdwryService.getZhxxdwry());

    }

    @ApiOperation(value = "责任人-明细", notes = "责任人-明细")
    @GetMapping("/getZhxxdwryDetail")
    public Result<List<BsZhxxdwryDetailDTO>> getZhxxdwryDetail(String streetName) {

        return Result.ok(zhxxdwryService.getZhxxdwryDetail(streetName));

    }

    @ApiOperation(value = "搜索资源")
    @PostMapping("/search")
    public Result getTreeList(@RequestBody ResourceSearchDTO dto) {
        return Result.ok(jzwzcbkdService.search(dto));

    }



}
